home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / source / Library / XYPlane.mod < prev   
Text File  |  1995-06-29  |  3KB  |  117 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: XYPlane.mod $
  4.   Description: Basic facilities for graphics programming.
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 1.5 $
  8.       $Author: fjc $
  9.         $Date: 1995/06/04 23:22:41 $
  10.  
  11.   Copyright © 1994-1995, Frank Copeland.
  12.   This file is part of the Oberon-A Library.
  13.   See Oberon-A.doc for conditions of use and distribution.
  14.  
  15. *************************************************************************)
  16.  
  17. <* STANDARD- *>
  18.  
  19. MODULE XYplane;
  20.  
  21. IMPORT
  22.   SYS := SYSTEM, Kernel, gfx := Graphics, i := Intuition,
  23.   as := AmigaSupport, InputPO;
  24.  
  25. CONST
  26.   draw *= 1;
  27.   erase *= 0;
  28.  
  29. VAR
  30.   X -, Y -, W -, H -: INTEGER;
  31.  
  32. CONST
  33.   drawPen = 1;
  34.   erasePen = 0;
  35.  
  36. PROCEDURE Open *;
  37. BEGIN (* Open *)
  38.   IF as.scr = NIL THEN
  39.     as.OpenDisplay;
  40.     X := 0; Y := 0; W := as.W; H := as.H;
  41.   END
  42. END Open;
  43.  
  44.  
  45. PROCEDURE Clear *;
  46.  
  47. BEGIN (* Clear *)
  48.   as.BeginUpdate;
  49.     IF as.win # NIL THEN
  50.       gfx.SetRast (as.win.rPort, erasePen);
  51.       i.RefreshWindowFrame (as.win)
  52.     END;
  53.   as.EndUpdate
  54. END Clear;
  55.  
  56.  
  57. PROCEDURE Dot * ( x, y, mode : INTEGER );
  58.  
  59.   VAR rp : gfx.RastPortPtr;
  60.  
  61. BEGIN (* Dot *)
  62.   ASSERT ((x >= 0) & (y >= 0) & ((mode = draw) OR (mode = erase)), 97);
  63.   as.BeginUpdate;
  64.     IF as.win # NIL THEN
  65.       (* Map Oberon co-ordinates to window co-ordinates *)
  66.       x := x + as.win.borderLeft;
  67.       y := as.win.height - as.win.borderBottom - y - 1;
  68.       (* Clip to window boundaries *)
  69.       IF (x < (as.win.width - as.win.borderRight)) & (y > as.win.borderTop) THEN
  70.         rp := as.win.rPort;
  71.         IF mode = draw THEN gfx.SetAPen (rp, drawPen)
  72.         ELSE gfx.SetAPen (rp, erasePen)
  73.         END;
  74.         gfx.SetDrMd (rp, gfx.jam1);
  75.         IF gfx.WritePixel (rp, x, y) THEN END;
  76.       END;
  77.     END;
  78.   as.EndUpdate
  79. END Dot;
  80.  
  81.  
  82. PROCEDURE IsDot * ( x, y : INTEGER ) : BOOLEAN;
  83.  
  84.   VAR result : BOOLEAN;
  85.  
  86. BEGIN (* IsDot *)
  87.   ASSERT ((x >= 0) & (y >= 0), 97);
  88.   result := FALSE;
  89.   as.BeginUpdate;
  90.     IF as.win # NIL THEN
  91.       (* Map Oberon co-ordinates to window co-ordinates *)
  92.       x := x + as.win.borderLeft;
  93.       y := as.win.height - as.win.borderBottom - y - 1;
  94.       (* Clip to window boundaries *)
  95.       IF (x < (as.win.width - as.win.borderRight))
  96.        & (y > as.win.borderTop)
  97.       THEN
  98.         result := gfx.ReadPixel (as.win.rPort, x, y) # erasePen
  99.       END
  100.     END;
  101.   as.EndUpdate;
  102.   RETURN result
  103. END IsDot;
  104.  
  105.  
  106. PROCEDURE Key * () : CHAR;
  107.  
  108.   VAR ch : CHAR;
  109.  
  110. BEGIN (* Key *)
  111.   InputPO.Read (ch);
  112.   RETURN ch
  113. END Key;
  114.  
  115.  
  116. END XYplane.
  117.